/**
 *
 * Copyright by Samuel Castro & Joaquim Fonseca, 2011
 * All Rights Reserved
 *
 * NOTES:
 * Please do not redistribute this plugin without my permission
 * Plugin made for private use only
 *
 */
package com.SySammy.SdCurrency;

import com.SySammy.SdCurrency.Handlers.CurrencyHandler;
import com.SySammy.SdCurrency.Prop.CurrencyProperties;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

/**
 *
 * @author Sammy
 */
public class sdPlayerListener extends PlayerListener {

    private CurrencyHandler CH = new CurrencyHandler();

    @Override
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player ply = (Player) event.getPlayer();
        if (!CH.hasAccount(ply.getName())) {
            Inventory plyInv = ply.getInventory();
            ItemStack Bones = new ItemStack(352);
            Bones.setAmount(CurrencyProperties.initialBones);
            ItemStack Slimes = new ItemStack(341);
            Slimes.setAmount(CurrencyProperties.initialSlimes);
            CH.MakeAccount(ply, CurrencyProperties.initialValues);
            plyInv.addItem(Bones);
            plyInv.addItem(Slimes);
            ply.sendMessage(ChatColor.GOLD + "Welcome to the server " + event.getPlayer().getName() + ", you were awarded with: ");
            ply.sendMessage("Money: " + ChatColor.GOLD + CurrencyProperties.initialMoney + " " + CurrencyProperties.Currency);
            ply.sendMessage("Bones: " + ChatColor.GOLD + CurrencyProperties.initialBones);
            ply.sendMessage("Slimes: " + ChatColor.GOLD + CurrencyProperties.initialSlimes);
        }
    }
}
